﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace blackhouse.WebNemo.Translator {
    internal static class TranslateKey {

        internal static TranslateKeyInfo ParseKey(string key) {
            TranslateKeyInfo keyInfo = new TranslateKeyInfo();
            string[] keyParts = key.Split('-');
            if (Int32.TryParse(keyParts[1], out keyInfo.GroupId)
                && Int32.TryParse(keyParts[2], out keyInfo.ColumnId)
                && Int32.TryParse(keyParts[3], out keyInfo.RecordId))
                return keyInfo;
            else
                return default(TranslateKeyInfo);
        }

        internal static string GetKey(int groupId, int columnId, int recordId) {
            return String.Format("wn-{0}-{1}-{2}", groupId, columnId, recordId);
        }

    }

    internal struct TranslateKeyInfo {

        public int GroupId;
        public int ColumnId;
        public int RecordId;

    }

}
